<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>https://cn.vuejs.org/v2/guide/list.html</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="bootstrap.css">
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="vue.js"></script>
    <script type="text/javascript" src="bootstrap.js"></script>
</head>
<body>
<div class="container" id="box">
    <div class="row">
        <div class="col-lg-12">
            <div class="row">
                <div class="panel panel-info">
                    <div class="panel-heading panel-title">
                        <div class="h3 text-success text-center">
                            github
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <button class="form-control btn-success" v-on:click="getInfo">INFO</button>
                        </div>
                        <div class="form-group">
                            <button class="form-control btn-danger" v-on:click="getApi">GET</button>
                        </div>
                        <div class="panel panel-success hide" id="user">
                            <div class="panel-heading panel-title">
                                <div class="row">
                                    <div class="col-xs-3 col-sm-3 col-md-2 col-lg-2">
                                        <img v-bind:src="user.avatar_url"
                                             v-bind:alt="user.name" class="img-circle img-responsive">
                                        <span class="alert text-center text-success">{{ user.name }}</span>
                                    </div>
                                    <div class="col-xs-9 col-sm-9 col-md-10 col-lg-10">
                                        <ul class="list-group">
                                            <li class=" list-unstyled" v-for="(v,k) in user">
                                                {{ k }} : {{ v }}
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="panel panel-danger hide" id="api">
                            <div class="panel-heading panel-title">
                                <div class="h4 panel-danger">
                                    <ul class="list-group">
                                        <li class="list-group-item" v-for="(value,key) in api.all">{{key}} : {{value}}
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript">
    var vue = new Vue({
        el: "#box",
        data: {
            user: {
                id: '',
                avatar_url: '',
                url: '',
                name: '',
                company: '',
                location: '',
                bio: '',
                created_at: '',
                updated_at: ''
            },
            url: {
                github: 'https://api.github.com/',
                user_url: 'https://api.github.com/users/zhangrxiang'
            },
            api: {
                all: undefined,
                user: undefined
            }
        },
        methods: {
            getApi: function () {
                $.get(this.url.github, undefined, function (data) {
                    vue.api.all = data;
                    $('#api').removeClass('hide').show(1000)
                }, 'json')
            },
            getInfo: function () {
                $.get(this.url.user_url, undefined, function (data) {
                    vue.user = data;
                    $('#user').removeClass('hide').show(1000)
                }, 'json')
            }
        }
    });
</script>